<template>
	<view style="margin-top: 13px;">
		<view id="xieyidetail">
		    <view class="content">
				<mp-html :content="content" />
		    </view>
		</view>
		<view id="xieyibottom">
		    <view>
				<u-radio-group v-model="value" @change="radioGroupChange">
					<u-radio v-for="(item, index) in list" :key="index" :name="item.name" :disabled="item.disabled">
						{{item.name}}
					</u-radio>
				</u-radio-group>
			</view>
			<view style="text-align: center; margin-top: 16px;">
				<button type="button" @click="goRugu()" class="rugu">产品入股</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				gid:'',	//商品ID
				list: [
					{
						name: '我已认真阅读并接受协议',
						disabled: false
					}
				],
				content:'',	//入股协议内容
				// u-radio-group的v-model绑定的值如果设置为某个radio的name，就会被默认选中
				value: 'orange',
				isXuanzhong:false,//判断是否勾选协议
			}
		},
		onLoad(opt) {
			this.gid = opt.gid
			this.getRuguInfo()
		},
		methods: {
			getRuguInfo(){
				this.$http.get('/ppgoods/getGoodsInfoByIdxcx',{
					gid: this.gid,
					userid:uni.getStorageSync('usersId')
				}).then(res => {
					if(res.data.code==200){
						this.content = res.data.data[0].ruguXieyi;
					}
				})
			},
			// 选中某个单选框时，由radio时触发
			radioChange(e) {
				
			},
			// 选中任一radio时，由radio-group触发
			radioGroupChange(e) {
				this.isXuanzhong = true;
			},
			goRugu(){
				if(!this.isXuanzhong){
					this.$u.toast("请先同意入股协议")
				}else{
					console.log("入股去")
					uni.navigateTo({
						url:'goodsRugu?gid='+this.gid
					})
				}
			}
		}
	}
</script>

<style>
	.content{
		color: #8f8f94;
	}
	.rugu{
		width: 200rpx;
		height: 70rpx;
		font-size: 14px;
		color: white;
		line-height: 70rpx;
		background-color: #dd524d;
	}
	#xieyidetail{
		height: 300px;
		overflow: auto;
		background-color: white;
	}
	#xieyibottom{
		padding: 10px;
	}
	#okbox{
		margin-top: 10px;
		text-align: center;
	}
</style>
